<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>做纯字符检测</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ctype-alpha" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ctype_alpha</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ctype_alpha</span> &mdash; <span class="dc-title">做纯字符检测</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ctype-alpha-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ctype_alpha</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   查看提供的<span class="type"><a href="language.types.string.html" class="type string">string</a></span>，<code class="parameter">text</code>里面的所有字符是否只包含字符。
   在标准的 <em>C</em> 语言环境下，字母仅仅是指
   <em>[A-Za-z]</em> ， <span class="function"><strong>ctype_alpha()</strong></span> 等同于
   <em>(ctype_upper($text) || ctype_lower($text))</em>
   如果 <code class="parameter">text</code> 是简单的单个字符串还好，但是在其他语言中有些字母被认为既不是大写也不是小写。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ctype-alpha-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">text</code></dt>

     <dd>

      <p class="para">
       被测试的字符串。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ctype-alpha-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果在当前语言环境中 <code class="parameter">text</code> 里的每个字符都是一个字母，那么就返回<strong><code>TRUE</code></strong>，反之则返回<strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ctype-alpha-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6161">
    <p><strong>Example #1 一个 <span class="function"><strong>ctype_alpha()</strong></span> 例子（使用默认的语言环境）</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$strings&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'KjgWZC'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arf12'</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$strings&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">ctype_alpha</span><span style="color: #007700">(</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;consists&nbsp;of&nbsp;all&nbsp;letters.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;does&nbsp;not&nbsp;consist&nbsp;of&nbsp;all&nbsp;letters.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The string KjgWZC consists of all letters.
The string arf12 does not consist of all letters.
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.ctype-alpha-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
如果给出一个 -128 到 255 之间(含)的整数, 将会被解释为该值对应的ASCII字符 (负值将加上 256 以支持扩展ASCII字符).
其它整数将会被解释为该值对应的十进制字符串.</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ctype-alpha-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="ctype_upper.html" class="function" rel="rdfs-seeAlso">ctype_upper()</a> - 做大写字母检测</span></li>
    <li class="member"><span class="function"><a href="ctype_lower.html" class="function" rel="rdfs-seeAlso">ctype_lower()</a> - 做小写字符检测</span></li>
    <li class="member"><span class="function"><a href="setlocale.html" class="function" rel="rdfs-seeAlso">setlocale()</a> - 设置地区信息</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>